package com.sbc.thread;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

/**
 * @description: 基于线程池实现的定时任务
 * @author: songbaicheng
 * @create: 2024/8/27 17:39
 **/
public class Test {
    public static void main(String[] args) {
        ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);

        executorService.scheduleAtFixedRate(() -> System.out.println("定时任务执行"), 0, 1, java.util.concurrent.TimeUnit.SECONDS);
    }
}
